<?php

class GeneralController extends Controller
{
    public $layout = '//layouts/general';
    
    /**
	 * @return array action filters
	 */
	public function filters()
	{
		return array(
			'rights', // perform access control for CRUD operations
		);
	}
    
    // Action dùng d? thanh toán bàn riêng
    public function actionIndex()
    {
        $this->current_page = 'general';
        
        $stadiumType7 = StadiumTypes::model()->findByAttributes(array('size'=>7));
        $stadiums7 = Stadiums::model()->findAllByAttributes(array('stadium_type_id'=>$stadiumType7->id,'visible' => 1));
        
        $stadiumType5 = StadiumTypes::model()->findByAttributes(array('size'=>5));
        $stadiums5 = Stadiums::model()->findAllByAttributes(array('stadium_type_id'=>$stadiumType5->id,'visible' => 1));
        
        $tables = Yii::app()->settings->get('system', 'table');
        
        $announcements = Announcement::model()->findAll(
            array(                
                'order' => 'id desc',
                'limit' => '3'
            )
        );
        
        Yii::app()->session['announcements'] = $announcements;
        
        // Tinh trang nuoc uong va quan ao
        
        $supplies = Supplies::model()->findAll(
            array(
                'condition' => 't.unit != "Không xác định"', 
                'order' => 'number',
                'limit' => '3'
            )
        );
        Yii::app()->session['supplies'] = $supplies;
        
        
        $this->render('index',array(
            'stadiums7'=>$stadiums7,
            'stadiums5'=>$stadiums5,
            'tables'=>$tables,            
        ));
    }
}